/********************************************************************************************/
/* TestCases.cc: Program file for storing and retrieving labels and addresses.              */
/* Author: Faiz-ur Rahman                                                                   */
/* ID: 82748328                                                                             */
/* Revisions:                                                                               */
/*				03/21/12 - Initial creation                                                 */
/********************************************************************************************/

#ifndef DICTIONARY_H
#define DICTIONARY_H

#include <iostream>
#include <vector>

using namespace std;

class dictionary
{
	vector<string> * label;
	vector<unsigned int> * address;

	public:
		dictionary()
		{
			label = new vector<string>;
			address = new vector<unsigned int>;
		}

		~dictionary()
		{
			delete label;
			delete address;
		}

		vector<string> * getlab()
		{
			return label; //pointer
		}

		string getlab(unsigned int i)
		{
			return (*label)[i];
		}

		vector<unsigned int> * getaddr()
		{
			return address; //pointer
		}

		unsigned int getaddr(unsigned int i)
		{
			return (*address)[i];
		}

		void store(string LABEL, unsigned int ADDRESS)
		{
			(*label).push_back(LABEL);
			(*address).push_back(ADDRESS);
		}

		unsigned int searchLAB(string LABEL)
		{
			unsigned int i;
			for(i = 0;i < (*label).size();i++)
			{
				if ((*label)[i].compare(LABEL) == 0)
				{
						return (*address)[i];
				}
			}
			return 4294967295; //ERROR
		}

		string searchADDR(unsigned int ADDRESS)
		{
			unsigned int i;
			for(i = 0;i < (*address).size();i++)
			{
				if ((*address)[i] == ADDRESS)
				{
						return (*label)[i];
				}
			}
			return ""; //ERROR
		}
};

#endif /* DICTIONARY_H */

/* EOF dictionary.h */
